<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>用户登陆</title>
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
	<link rel="stylesheet" href="#(path)/assets/bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" href="#(path)/assets/css/AdminLTE.min.css">
	<script src="#(path)/assets/plugins/jQuery/jquery-2.2.3.min.js"></script>
	<script src="#(path)/assets/js/getpass.js"></script> 
	<script src="#(path)/assets/js/elink.js"></script>
	<script src="#(path)/assets/plugins/layer/layer.js"></script>
	
</head>
<style type=text/css>
body {
	background: #ACD6FF;
	background-size: 100%;
}
</style>
<body>
	<div class="login-box">
		<div class="login-logo">
			<img src="#(path)/assets/img/logo.png" width=100px>
		</div>
		<div class="login-box-body" style="border-radius: 10px;">
			#if(msg)
			<p class="login-box-msg" style="color: #930000">#(msg)</p>
			#end
				<div class="form-group has-feedback">
					<input type="text" id="workcode" class="form-control" placeholder="请输入工号..."> 
					<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
				</div> 
				<div class="form-group has-feedback">
					<input type="password"  id="password" class="form-control" placeholder="请输入密码..."> 
					<span class="glyphicon glyphicon-lock form-control-feedback"></span>
				</div>
				<div class="form-group has-feedback">
					<button id="submitlogin" type="submit" class="submit btn btn-success btn-block btn-flat">开始登陆</button>
				</div>
			
		</div>
	</div>
	
<script>
$(function() {
	$('#submitlogin').click(function(){
		ajax("#(path)/user/login?aes=0",{"workcode":$('#workcode').val(),"password":$('#password').val(),"type":"backend"}, function(data){ 
			var redirectUrl = $.isBlank(GetRequest().redirectUrl)?"#(path)/admin/page/index-index":GetRequest().redirectUrl;
			if(data.code=='success'){
				layer.msg(data.msg, {time: 800, icon:1},function(){
					//console.log(data);
					// 登陆成功，执行跳转...
					window.location.href=unescape(redirectUrl);
				});
			}else if(data.code=='error'){
				layer.msg(data.msg, {icon:2},function(){
					// 登陆失败，提醒错误...
				});
			}
		});
	});
});
//AES-128-CBC加密模式，key需要为16位，key和iv可以一样
function encrypt(data) {
	var key  = CryptoJS.enc.Latin1.parse('wjc_is_very_good');
	var iv   = CryptoJS.enc.Latin1.parse('wjc_is_very_good');
	return CryptoJS.AES.encrypt(data, key, {iv:iv,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.ZeroPadding}).toString();
}
function GetRequest() {  
   var url = location.search; //获取url中"?"符后的字串  
   var theRequest = new Object();  
   if (url.indexOf("?") != -1) {  
      var str = url.substr(1);  
      strs = str.split("&");  
      for(var i = 0; i < strs.length; i ++) {  
         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);  
      }  
   }  
   return theRequest;  
} 
</script>
</body>
</html>
